package com.sz.designpattern.behavior11.interpreter;

/**
 * 非终极符表达式
 */
public class AddExpression extends ArithmeticExpression{
    private ArithmeticExpression left,right;

    public AddExpression(ArithmeticExpression left, ArithmeticExpression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    protected Object interpret(Context context) {
        return context.get((String) left.interpret(context))
                +
                context.get((String) right.interpret(context));
    }

}
